#include<iostream>
#include<unistd.h>
#include"TimeWheel.hpp"

struct Test{
    Test(){std::cout<<"Test"<<std::endl;}
    ~Test(){std::cout<<"~Test"<<std::endl;}
};
void DelTest(Test *p){
        delete p;
}
int main()
{
    Test *t = new Test();

    TimeWheel tw;
    std::cout<<"Map size: "<<tw.GetMapSize()<<std::endl;
    tw.AddTimeTask(100,5,std::bind(DelTest,t));
    int second  = 5;
    while(second--){
        std::cout<<"-------TimeWheel run------"<<std::endl;
        tw.DelayTimeTask(100);//延时
        tw.RunTimeWheel();//
        sleep(1);

    }
    tw.CancelTimeTask(100);
    while(1){
        sleep(1);
        std::cout<<"走了一步"<<std::endl;
        tw.RunTimeWheel();//
        std::cout<<"Map size: "<<tw.GetMapSize()<<std::endl;
    }
    return 0;
}

